package com.lf.web.service.system.extension;

import com.lf.data.Validate;
import com.lf.data.search.Query;
import com.lf.web.service.ResponseCode;
import com.lf.web.service.ResponseInfo;
import com.lf.web.service.ServiceSupport;
import org.apache.log4j.Logger;

import java.util.List;

public class ExtensionRemoveService extends ServiceSupport {

    private static final Logger LOGGER = Logger.getLogger(ExtensionRemoveService.class);
    private ExtensionDAO extensionDAO;

    public void setExtensionDAO(ExtensionDAO extensionDAO) {
        this.extensionDAO = extensionDAO;
    }

    public String execute() {
        List<String> ids = form.getList("id");
        LOGGER.debug("删除插件：id=" + ids);
        if (Validate.check(Validate.OBJECTID, ids)) {
            ResponseInfo rj = new ResponseInfo();
            Query query = new Query();
            query.idIn(ids);
            extensionDAO.remove(query);
            rj.setCode(ResponseCode.FINISH);
            out(rj);
        } else {
            LOGGER.error("非法删除插件：id=" + ids);
            error(404);
        }
        return NONE;
    }

}
